import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: ' ',
    align: 'center',
    dataIndex: '',
    slots: { customRender: 'Index' },
    width: 80,
  },
  {
    title: '商品图片',
    align: 'center',
    dataIndex: 'images',
    slots: { customRender: 'isShow' },
    resizable: true,
  },
  {
    title: '基础信息',
    align: 'center',
    dataIndex: '',
    slots: { customRender: 'Foundation' },
    width: 300,
    resizable: true,
  },
  {
    title: '订单详情',
    align: 'center',
    dataIndex: 'images',
    slots: { customRender: 'Detail' },
    width: 240,
    resizable: true,
  },
  {
    title: '金额数量',
    align: 'center',
    dataIndex: 'images',
    slots: { customRender: 'Number' },
    resizable: true,
  },
  {
    title: '平台利润',
    align: 'center',
    dataIndex: 'profit',
    width: 100,
    resizable: true,
  },
  {
    title: '买家会员名',
    align: 'center',
    dataIndex: 'buyerNick',
    resizable: true,
  },

  {
    title: '所属账号',
    align: 'center',
    dataIndex: 'sellerName',
    resizable: true,
  },
  {
    title: '备注信息',
    align: 'center',
    dataIndex: '',
    slots: { customRender: 'Remake' },
    width: 200,
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '订单号',
    field: 'orderNo',
    component: 'Input', //TODO 范围查询
    //colProps: {span: 6},
  },
  {
    label: '商品ID',
    field: 'itemId',
    component: 'Input', //TODO 范围查询
    //colProps: {span: 6},
  },

  {
    label: '所属账号',
    field: 'sellerName',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_goodfish_sell,seller_name,seller_name',
    },
    auth: 'card:app_goodfish_order:admin',
  },
  {
    label: '买家姓名',
    field: 'buyerNick',
    component: 'Input', //TODO 范围查询
    //colProps: {span: 6},
  },
  {
    label: '商品标题',
    field: 'title',
    component: 'Input', //TODO 范围查询
    //colProps: {span: 6},
  },
  {
    label: '买家手机号',
    field: 'receiverMobile',
    component: 'Input', //TODO 范围查询
    //colProps: {span: 6},
  },
  {
    label: '订单状态',
    field: 'orderStatus',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'xy_order_status',
    },

    //colProps: {span: 6},
  },
  {
    label: '是否绑定卡券',
    field: 'isBind',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'yn',
    },
  },
  {
    field: 'createTime',
    label: '创建时间',
    component: 'RangePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
    },
  },
  // {
  //   label: '失效时间',
  //   field: 'dateTimeRangeSelect',
  //   component: 'RangePicker',
  //   componentProps: {
  //     //是否显示时间
  //     showTime: true,
  //     //日期格式化
  //     format: 'YYYY/MM/DD',
  //     //范围文本描述用集合
  //     placeholder: ['请选择开始日期时间', '请选择结束日期时间'],
  //   },
  // },
  // {
  //   label: '绑定状态',
  //   field: 'useState',
  //   component: 'JDictSelectTag',
  //   componentProps: {
  //     dictCode: 'card_use_state',
  //   },
  //   //colProps: {span: 6},
  // },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '卡券ID',
    field: 'orderNo',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入闲鱼订单号!' }];
    },
  },
];
//子表单数据
//子表表格配置
export const cardColumns: JVxeColumn[] = [
  {
    title: '兑换码',
    key: 'code',
    type: JVxeTypes.input,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '券码',
    key: 'couponCode',
    type: JVxeTypes.image,
    token: true,
    responseName: 'message',
    number: 1,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '使用状态',
    key: 'useState',
    type: JVxeTypes.select,
    options: [],
    dictCode: 'card_use_state',
    disabled: true,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '0',
    validateRules: [{ required: true, message: '${title}不能为空' }],
  },
  {
    title: '上传用户',
    key: 'memberId',
    type: JVxeTypes.select,
    options: [],
    dictCode: 'app_member,nick_name,id',
    disabled: true,
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: 'admin',
  },
  {
    title: '状态',
    key: 'state',
    type: JVxeTypes.select,
    options: [],
    dictCode: 'card_state',
    width: '200px',
    placeholder: '请输入${title}',
    defaultValue: '1',
    validateRules: [{ required: true, message: '${title}不能为空' }],
  },
  // {
  //   title: '上架状态',
  //   key: 'groundingState',
  //   type: JVxeTypes.select,
  //   options:[],
  //   dictCode:"card_grounding",
  //   width:"200px",
  //   placeholder: '请输入${title}',
  //   defaultValue:"1",
  //     validateRules: [
  //       { required: true, message: '${title}不能为空' },
  //     ],
  // },
];

//一键激活表单数据
export const jiHuoSchema: FormSchema[] = [
  {
    label: '激活原因',
    field: 'reason',
    component: 'InputTextArea',
    componentProps: {
      //可以点击清除图标删除内容
      allowClear: true,
      //是否展示字数
      showCount: true,
      //自适应内容高度，可设置为 true | false 或对象：{ minRows: 2, maxRows: 6 }
      autoSize: {
        //最小显示行数
        minRows: 5,
        //最大显示行数
        maxRows: 8,
      },
    },
    dynamicRules: () => {
      return [{ required: true, message: '请输入激活原因!' }];
    },
  },
  {
    label: '备注咸鱼订单号',
    field: 'remarkOrderNo',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: false, message: '请输入备注咸鱼订单号!' }];
    },
  },
];

//发货表单数据
export const sendformSchema: FormSchema[] = [
  {
    label: '闲鱼订单号',
    field: 'orderNo',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入闲鱼订单号!' }];
    },
    dynamicDisabled: true,
  },
  {
    label: '闲鱼卡券id',
    field: 'cardIds',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入闲鱼卡券id!' }];
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  orderNo: { title: '闲鱼订单号', order: 0, view: 'text', type: 'string' },
  title: { title: '商品标题', order: 1, view: 'text', type: 'string' },
  images: { title: '商品图片', order: 2, view: 'image', type: 'string' },
  buyerNick: { title: '买家昵称', order: 3, view: 'text', type: 'string' },
  price: { title: '商品单价', order: 4, view: 'number', type: 'number' },
  orderStatus: { title: '订单状态', order: 5, view: 'number', type: 'number', dictCode: 'xy_order_status' },
  payAmount: { title: '订单实付金额', order: 6, view: 'number', type: 'number' },
  refundStatus: { title: '订单退款状态', order: 9, view: 'number', type: 'number', dictCode: 'xy_refund_status' },
  //子表高级查询
  card: {
    title: '卡券',
    view: 'table',
    fields: {
      code: { title: '兑换码', order: 0, view: 'text', type: 'string' },
      couponCode: { title: '券码', order: 1, view: 'image', type: 'string' },
      useState: { title: '使用状态', order: 2, view: 'list', type: 'string', dictCode: 'card_use_state' },
      memberId: { title: '上传用户', order: 3, view: 'list', type: 'string', dictTable: 'app_member', dictCode: 'id', dictText: 'nick_name' },
      useTime: { title: '使用时间', order: 4, view: 'datetime', type: 'string' },
      state: { title: '状态', order: 5, view: 'list', type: 'string', dictCode: 'card_state' },
      groundingState: { title: '上架状态', order: 6, view: 'list', type: 'string', dictCode: 'card_grounding' },
    },
  },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
